import React, { Component } from 'react'
import Item from '../Item'
import PropTypes from 'prop-types'//这里需要安装npm i prop-types
import './index.css'
export default class List extends Component {
    //对接受到的props进行：类型、必要性的限制
    static propTypes = {
        updateTodo: PropTypes.func.isRequired,
        todos: PropTypes.array.isRequired,
        delTodo: PropTypes.func.isRequired,
    }
    render() {
        const { todos, updateTodo, delTodo } = this.props
        return (
            <ul className="todo-main">
                {
                    todos.map(todo => {
                        return <Item updateTodo={updateTodo} delTodo={delTodo} key={todo.id} {...todo} />
                    })
                }

            </ul>
        )
    }
}
